home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0361 / settime.frm < prev    next >
Text File  |  1997-03-31  |  21KB  |  783 lines

  1. VERSION 2.00
  2. Begin Form SetTimeForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Set Time"
  6.    ClientHeight    =   1305
  7.    ClientLeft      =   2970
  8.    ClientTop       =   3315
  9.    ClientWidth     =   3570
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   1740
  13.    Left            =   2895
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   1305
  18.    ScaleWidth      =   3570
  19.    Top             =   2955
  20.    Width           =   3720
  21.    Begin SSCommand Command3D1 
  22.       Height          =   465
  23.       Left            =   165
  24.       Picture         =   SETTIME.FRX:0000
  25.       TabIndex        =   18
  26.       Top             =   720
  27.       Width           =   540
  28.    End
  29.    Begin CommandButton Command1 
  30.       Cancel          =   -1  'True
  31.       Caption         =   "Cancel"
  32.       Height          =   360
  33.       Index           =   1
  34.       Left            =   2265
  35.       TabIndex        =   20
  36.       Top             =   765
  37.       Width           =   1155
  38.    End
  39.    Begin CommandButton Command1 
  40.       Caption         =   "Set"
  41.       Default         =   -1  'True
  42.       Height          =   360
  43.       Index           =   0
  44.       Left            =   885
  45.       TabIndex        =   19
  46.       Top             =   765
  47.       Width           =   1155
  48.    End
  49.    Begin PictureBox SpinButton 
  50.       AutoSize        =   -1  'True
  51.       BackColor       =   &H00C0C0C0&
  52.       Height          =   360
  53.       Index           =   1
  54.       Left            =   3255
  55.       ScaleHeight     =   330
  56.       ScaleWidth      =   135
  57.       TabIndex        =   17
  58.       TabStop         =   0   'False
  59.       Top             =   240
  60.       Width           =   165
  61.    End
  62.    Begin SSFrame Frame3D1 
  63.       ForeColor       =   &H00000000&
  64.       Height          =   444
  65.       Index           =   1
  66.       Left            =   1830
  67.       TabIndex        =   11
  68.       Top             =   156
  69.       Width           =   1395
  70.       Begin TextBox tYear 
  71.          BackColor       =   &H00C0C0C0&
  72.          BorderStyle     =   0  'None
  73.          Height          =   225
  74.          Left            =   780
  75.          MaxLength       =   4
  76.          TabIndex        =   14
  77.          Tag             =   "y"
  78.          Text            =   "1955"
  79.          Top             =   150
  80.          Width           =   480
  81.       End
  82.       Begin TextBox tDay 
  83.          BackColor       =   &H00C0C0C0&
  84.          BorderStyle     =   0  'None
  85.          Height          =   225
  86.          Left            =   450
  87.          MaxLength       =   2
  88.          TabIndex        =   13
  89.          Tag             =   "d"
  90.          Text            =   "17"
  91.          Top             =   150
  92.          Width           =   240
  93.       End
  94.       Begin TextBox tMonth 
  95.          Alignment       =   1  'Right Justify
  96.          BackColor       =   &H00C0C0C0&
  97.          BorderStyle     =   0  'None
  98.          Height          =   225
  99.          Left            =   120
  100.          MaxLength       =   2
  101.          TabIndex        =   12
  102.          Tag             =   "n"
  103.          Text            =   "09"
  104.          Top             =   150
  105.          Width           =   240
  106.       End
  107.       Begin Label Label1 
  108.          Alignment       =   2  'Center
  109.          BackColor       =   &H00C0C0C0&
  110.          Caption         =   "/"
  111.          Height          =   225
  112.          Index           =   3
  113.          Left            =   690
  114.          TabIndex        =   16
  115.          Top             =   150
  116.          Width           =   105
  117.       End
  118.       Begin Label Label1 
  119.          Alignment       =   2  'Center
  120.          BackColor       =   &H00C0C0C0&
  121.          Caption         =   "/"
  122.          Height          =   225
  123.          Index           =   2
  124.          Left            =   345
  125.          TabIndex        =   15
  126.          Top             =   150
  127.          Width           =   105
  128.       End
  129.    End
  130.    Begin PictureBox SpinButton 
  131.       AutoSize        =   -1  'True
  132.       BackColor       =   &H00C0C0C0&
  133.       Height          =   360
  134.       Index           =   0
  135.       Left            =   1590
  136.       ScaleHeight     =   330
  137.       ScaleWidth      =   135
  138.       TabIndex        =   7
  139.       TabStop         =   0   'False
  140.       Top             =   240
  141.       Width           =   165
  142.    End
  143.    Begin PictureBox N 
  144.       AutoSize        =   -1  'True
  145.       Height          =   360
  146.       Left            =   2970
  147.       Picture         =   SETTIME.FRX:016A
  148.       ScaleHeight     =   330
  149.       ScaleWidth      =   135
  150.       TabIndex        =   6
  151.       TabStop         =   0   'False
  152.       Top             =   1995
  153.       Visible         =   0   'False
  154.       Width           =   165
  155.    End
  156.    Begin PictureBox U 
  157.       AutoSize        =   -1  'True
  158.       Height          =   360
  159.       Left            =   3180
  160.       Picture         =   SETTIME.FRX:0294
  161.       ScaleHeight     =   330
  162.       ScaleWidth      =   135
  163.       TabIndex        =   5
  164.       TabStop         =   0   'False
  165.       Top             =   1980
  166.       Visible         =   0   'False
  167.       Width           =   165
  168.    End
  169.    Begin PictureBox D 
  170.       AutoSize        =   -1  'True
  171.       Height          =   360
  172.       Left            =   3405
  173.       Picture         =   SETTIME.FRX:03BE
  174.       ScaleHeight     =   330
  175.       ScaleWidth      =   135
  176.       TabIndex        =   0
  177.       TabStop         =   0   'False
  178.       Top             =   1980
  179.       Visible         =   0   'False
  180.       Width           =   165
  181.    End
  182.    Begin SSFrame Frame3D1 
  183.       ForeColor       =   &H00000000&
  184.       Height          =   444
  185.       Index           =   0
  186.       Left            =   168
  187.       TabIndex        =   8
  188.       Top             =   156
  189.       Width           =   1392
  190.       Begin TextBox tHour 
  191.          Alignment       =   1  'Right Justify
  192.          BackColor       =   &H00C0C0C0&
  193.          BorderStyle     =   0  'None
  194.          Height          =   225
  195.          Left            =   120
  196.          MaxLength       =   2
  197.          MultiLine       =   -1  'True
  198.          TabIndex        =   1
  199.          Tag             =   "h"
  200.          Text            =   "12"
  201.          Top             =   150
  202.          Width           =   240
  203.       End
  204.       Begin TextBox tMinute 
  205.          BackColor       =   &H00C0C0C0&
  206.          BorderStyle     =   0  'None
  207.          Height          =   225
  208.          Left            =   456
  209.          MaxLength       =   2
  210.          TabIndex        =   2
  211.          Tag             =   "m"
  212.          Text            =   "00"
  213.          Top             =   150
  214.          Width           =   240
  215.       End
  216.       Begin TextBox tAMPM 
  217.          BackColor       =   &H00C0C0C0&
  218.          BorderStyle     =   0  'None
  219.          Height          =   225
  220.          Left            =   1020
  221.          TabIndex        =   4
  222.          Tag             =   "a"
  223.          Text            =   "am"
  224.          Top             =   150
  225.          Width           =   285
  226.       End
  227.       Begin TextBox tSecond 
  228.          BackColor       =   &H00C0C0C0&
  229.          BorderStyle     =   0  'None
  230.          Height          =   225
  231.          Left            =   780
  232.          MaxLength       =   2
  233.          TabIndex        =   3
  234.          Tag             =   "s"
  235.          Text            =   "00"
  236.          Top             =   150
  237.          Width           =   240
  238.       End
  239.       Begin Label Label1 
  240.          Alignment       =   2  'Center
  241.          BackColor       =   &H00C0C0C0&
  242.          Caption         =   ":"
  243.          Height          =   225
  244.          Index           =   0
  245.          Left            =   345
  246.          TabIndex        =   10
  247.          Top             =   150
  248.          Width           =   105
  249.       End
  250.       Begin Label Label1 
  251.          Alignment       =   2  'Center
  252.          BackColor       =   &H00C0C0C0&
  253.          Caption         =   ":"
  254.          Height          =   225
  255.          Index           =   1
  256.          Left            =   675
  257.          TabIndex        =   9
  258.          Top             =   150
  259.          Width           =   105
  260.       End
  261.    End
  262. End
  263. Option Explicit
  264. DefInt A-Z
  265. Dim LastY As Single
  266. Dim Active As String
  267. Dim LastDirection As String
  268. Dim tVal As Integer
  269.  
  270. ' Jeffrey M. Richter's Spin Button Control from Windows 3: A Developer's Guide
  271. ' Adapted for Visual Basic by Costas Kitsos with Mr. Richter's kind permission
  272.  
  273. ' Windows API functions used by the Spin Button Control
  274. Declare Function GetTickCount Lib "User" () As Long
  275. Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
  276.  
  277. Sub Command1_Click (Index As Integer)
  278. If Index = 0 Then
  279.   Time = tHour.Text + ":" + tMinute.Text + ":" + tSecond.Text + UCase$(tAMPM.Text)
  280.   Date = tMonth.Text + "/" + tDay.Text + "/" + tYear.Text
  281.   LastTime = 0
  282.   Unload SetTimeForm
  283. End If
  284. If Index = 1 Then
  285.   LastTime = 0
  286.   Unload SetTimeForm
  287. End If
  288.  
  289. End Sub
  290.  
  291. Sub Command3D1_Click ()
  292. AtomicTimeWasSet = False
  293. Atomic.Show 1
  294. Unload Atomic
  295. If AtomicTimeWasSet Then
  296.    Unload SetTimeForm
  297. End If
  298. End Sub
  299.  
  300. Sub FlipFlopTAMPM ()
  301.          If tAMPM.Text = "am" Then
  302.             tAMPM.Text = "pm"
  303.          Else
  304.             tAMPM.Text = "am"
  305.          End If
  306.  
  307. End Sub
  308.  
  309. Sub Form_GotFocus ()
  310.     tHour.SetFocus
  311.     DoEvents
  312.  
  313. End Sub
  314.  
  315. Sub Form_Load ()
  316. SetTimeForm.Left = Settings.Left + (Settings.Width / 2) - (SetTimeForm.Width / 2)
  317. SetTimeForm.Top = Settings.Top + (Settings.Height / 2) - (SetTimeForm.Height / 2)
  318. Dim Instant As Double
  319. Dim InitialHeight As Integer
  320.     InitialHeight = SpinButton(0).Height
  321.     SpinButton(0).Picture = N.Picture       'Set to the Normal Spin Button
  322.     SpinButton(0).Top = SpinButton(0).Top + (InitialHeight - SpinButton(0).Height) / 2
  323.     SpinButton(1).Picture = N.Picture       'Set to the Normal Spin Button
  324.     SpinButton(1).Top = SpinButton(1).Top + (InitialHeight - SpinButton(1).Height) / 2
  325.     Instant = Now
  326.     If Hour(Instant) = 0 Then
  327.        tHour.Text = "12"
  328.        tAMPM.Text = "am"
  329.     End If
  330.     If Hour(Instant) >= 1 And Hour(Instant) <= 11 Then
  331.        tHour.Text = Format$(Hour(Instant))
  332.        tAMPM.Text = "am"
  333.     End If
  334.     If Hour(Instant) = 12 Then
  335.        tHour.Text = Format$(Hour(Instant))
  336.        tAMPM.Text = "pm"
  337.     End If
  338.     If Hour(Instant) >= 13 And Hour(Instant) <= 23 Then
  339.        tHour.Text = Format$(Hour(Instant) - 12)
  340.        tAMPM.Text = "pm"
  341.     End If
  342.     tMinute.Text = Format$(Minute(Instant), "00")
  343.     tSecond.Text = Format$(Second(Instant), "00")
  344.     tMonth.Text = Format$(Month(Instant), "00")
  345.     tDay.Text = Format$(Day(Instant), "00")
  346.     tYear.Text = Format$(Year(Instant), "0000")
  347.     'SetTimeFOrm.Show
  348.     'DoEvents
  349.  
  350. End Sub
  351.  
  352. Sub MoveDown (c As Control)
  353. Dim CurVal As Integer
  354. CurVal% = Val(c.Text)
  355. Select Case c.Tag
  356.    Case "h"
  357.       If CurVal% = 12 Then
  358.          FlipFlopTAMPM
  359.       End If
  360.       If CurVal% = 1 Then
  361.          c.Text = "12"
  362.       Else
  363.          c.Text = Val(c.Text) - 1
  364.       End If
  365.    Case "m"
  366.       If CurVal% = 0 Then
  367.          c.Text = "59"
  368.       Else
  369.          c.Text = Format$(Val(c.Text) - 1, "00")
  370.       End If
  371.    Case "s"
  372.       If CurVal% = 0 Then
  373.          c.Text = "59"
  374.       Else
  375.          c.Text = Format$(Val(c.Text) - 1, "00")
  376.       End If
  377.    Case "a"
  378.       FlipFlopTAMPM
  379.    Case "n"
  380.       If CurVal% = 1 Then
  381.          c.Text = "12"
  382.       Else
  383.          c.Text = Format$(Val(c.Text) - 1, "00")
  384.       End If
  385.    Case "d"
  386.       If CurVal% = 1 Then
  387.          c.Text = "31"
  388.       Else
  389.          c.Text = Format$(Val(c.Text) - 1, "00")
  390.       End If
  391.    Case "y"
  392.       If CurVal% = 1 Then
  393.          c.Text = "2050"
  394.       Else
  395.          c.Text = Format$(Val(c.Text) - 1, "0000")
  396.       End If
  397. End Select
  398.  
  399. 'c.Text = Val(c.Text) - 1
  400. End Sub
  401.  
  402. Sub MoveUp (c As Control)
  403. Dim CurVal As Integer
  404. CurVal% = Val(c.Text)
  405. Select Case c.Tag
  406.    Case "h"
  407.       If CurVal% = 11 Then
  408.          FlipFlopTAMPM
  409.       End If
  410.       If CurVal% = 12 Then
  411.          c.Text = "1"
  412.       Else
  413.          c.Text = Val(c.Text) + 1
  414.       End If
  415.    Case "m"
  416.       If CurVal% = 59 Then
  417.          c.Text = "00"
  418.       Else
  419.          c.Text = Format$(Val(c.Text) + 1, "00")
  420.       End If
  421.    Case "s"
  422.       If CurVal% = 59 Then
  423.          c.Text = "00"
  424.       Else
  425.          c.Text = Format$(Val(c.Text) + 1, "00")
  426.       End If
  427.    Case "a"
  428.       FlipFlopTAMPM
  429.    Case "n"
  430.       If CurVal% = 12 Then
  431.          c.Text = "01"
  432.       Else
  433.          c.Text = Format$(Val(c.Text) + 1, "00")
  434.       End If
  435.    Case "d"
  436.       If CurVal% = 31 Then
  437.          c.Text = "01"
  438.       Else
  439.          c.Text = Format$(Val(c.Text) + 1, "00")
  440.       End If
  441.    Case "y"
  442.       If CurVal% = 2050 Then
  443.          c.Text = "1980"
  444.       Else
  445.          c.Text = Format$(Val(c.Text) + 1, "0000")
  446.       End If
  447.  
  448. End Select
  449.  
  450. End Sub
  451.  
  452. Sub SpinButton_DblClick (Index As Integer)
  453. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  454.    tMonth.SetFocus
  455. End If
  456. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  457.    tHour.SetFocus
  458. End If
  459. If LastDirection$ = "u" Then
  460.    Select Case Active$
  461.      Case "n"
  462.         Call MoveUp(tMonth)
  463.      Case "d"
  464.         Call MoveUp(tDay)
  465.      Case "y"
  466.         Call MoveUp(tYear)
  467.      Case "h"
  468.         Call MoveUp(tHour)
  469.      Case "m"
  470.         Call MoveUp(tMinute)
  471.      Case "s"
  472.         Call MoveUp(tSecond)
  473.      Case "a"
  474.         Call MoveUp(tAMPM)
  475.    End Select
  476. Else
  477.    Select Case Active$
  478.      Case "n"
  479.         Call MoveDown(tMonth)
  480.      Case "d"
  481.         Call MoveDown(tDay)
  482.      Case "y"
  483.         Call MoveDown(tYear)
  484.      Case "h"
  485.         Call MoveDown(tHour)
  486.      Case "m"
  487.         Call MoveDown(tMinute)
  488.      Case "s"
  489.         Call MoveDown(tSecond)
  490.      Case "a"
  491.         Call MoveDown(tAMPM)
  492.    End Select
  493. End If
  494. SpinButton(Index).SetFocus
  495. End Sub
  496.  
  497. Sub SpinButton_GotFocus (Index As Integer)
  498. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  499.    tMonth.SetFocus
  500.    Exit Sub
  501. End If
  502. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  503.    tHour.SetFocus
  504.    Exit Sub
  505. End If
  506.    Select Case Active$
  507.      Case "n"
  508.         tMonth.SetFocus
  509.      Case "d"
  510.         tDay.SetFocus
  511.      Case "y"
  512.         tYear.SetFocus
  513.      Case "h"
  514.         tHour.SetFocus
  515.      Case "m"
  516.         tMinute.SetFocus
  517.      Case "s"
  518.         tSecond.SetFocus
  519.      Case "a"
  520.         tAMPM.SetFocus
  521.    End Select
  522. End Sub
  523.  
  524. Sub SpinButton_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  525.  
  526. Const VK_LBUTTON = &H1
  527. Const TIME_DELAY = 180      ' Time delay between Spin Button Events
  528.  
  529. Dim dwEvent As Long
  530. LastY = Y
  531. ' Make sure that the Spin Button Event occurs at least once
  532. dwEvent = GetTickCount() - TIME_DELAY
  533.  
  534. SpinIt:
  535.  
  536.    ' Do this while the user holds down the left mouse button
  537.    Do While (GetAsyncKeyState(VK_LBUTTON) And &H8000) = -32768
  538.  
  539.         ' Break out of the loop if we haven't waited long enough
  540.         If dwEvent + TIME_DELAY > GetTickCount() Then GoTo Break:
  541.  
  542.         ' If the user wants to increment the counter
  543.         If Y > (SpinButton(Index).Height \ 2) Then
  544.             SpinButton(Index).Picture = d.Picture  ' Set Picture to Up
  545.             If Index = 1 Then
  546.             Select Case Active$
  547.                Case "n"
  548.                    Call MoveDown(tMonth)
  549.                Case "d"
  550.                    Call MoveDown(tDay)
  551.                Case "y"
  552.                    Call MoveDown(tYear)
  553.             End Select
  554.             End If
  555.             If Index = 0 Then
  556.             Select Case Active$
  557.                Case "h"
  558.                    Call MoveDown(tHour)
  559.                Case "s"
  560.                    Call MoveDown(tSecond)
  561.                Case "m"
  562.                    Call MoveDown(tMinute)
  563.                Case "a"
  564.                    Call MoveDown(tAMPM)
  565.             End Select
  566.             End If
  567.             LastDirection$ = "d"
  568.         End If
  569.  
  570.         ' If the user wants to decrement the counter
  571.         If Y < (SpinButton(Index).Height \ 2) Then
  572.             SpinButton(Index).Picture = u.Picture   ' Set Picture to Down
  573.             If Index = 1 Then
  574.             Select Case Active$
  575.                Case "n"
  576.                    Call MoveUp(tMonth)
  577.                Case "d"
  578.                    Call MoveUp(tDay)
  579.                Case "y"
  580.                    Call MoveUp(tYear)
  581.             End Select
  582.             End If
  583.             If Index = 0 Then
  584.             Select Case Active$
  585.                Case "h"
  586.                    Call MoveUp(tHour)
  587.                Case "s"
  588.                    Call MoveUp(tSecond)
  589.                Case "m"
  590.                    Call MoveUp(tMinute)
  591.                Case "a"
  592.                    Call MoveUp(tAMPM)
  593.             End Select
  594.             End If
  595.             LastDirection$ = "u"
  596.         End If
  597.  
  598.         ' Save the last time the Spin Button was active
  599.         dwEvent = GetTickCount()
  600.     Loop
  601.     
  602.     ' Set the Picture to Normal
  603.     SpinButton(Index).Picture = N.Picture
  604.     If Index = 1 Then
  605.     Select Case Active$
  606.        Case "n"
  607.           tMonth.SetFocus
  608.        Case "d"
  609.           tDay.SetFocus
  610.        Case "y"
  611.           tYear.SetFocus
  612.     End Select
  613.     End If
  614.     If Index = 0 Then
  615.     Select Case Active$
  616.        Case "h"
  617.           tHour.SetFocus
  618.        Case "m"
  619.           tMinute.SetFocus
  620.        Case "s"
  621.           tSecond.SetFocus
  622.        Case "a"
  623.           tAMPM.SetFocus
  624.     End Select
  625.     End If
  626.     DoEvents
  627.     
  628.     Exit Sub
  629.  
  630. Break:
  631.     GoTo SpinIt:
  632.  
  633. End Sub
  634.  
  635. Sub tAMPM_GotFocus ()
  636. tAMPM.SelStart = 0
  637. tAMPM.SelLength = 2
  638. Active$ = "a"
  639.  
  640. End Sub
  641.  
  642. Sub tAMPM_KeyPress (KeyAscii As Integer)
  643. If KeyAscii >= 32 Then
  644.    FlipFlopTAMPM
  645.    KeyAscii = 0
  646.    tAMPM.SelStart = 0
  647.    tAMPM.SelLength = 2
  648. End If
  649. End Sub
  650.  
  651. Sub tAMPM_LostFocus ()
  652. If tAMPM.Text <> "am" And tAMPM.Text <> "pm" Then
  653.    tAMPM.Text = "am"
  654. End If
  655.  
  656. End Sub
  657.  
  658. Sub tDay_GotFocus ()
  659. tDay.SelStart = 0
  660. tDay.SelLength = 2
  661. Active$ = "d"
  662. End Sub
  663.  
  664. Sub tDay_KeyPress (KeyAscii As Integer)
  665. If KeyAscii >= 32 Then
  666.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  667. End If
  668.  
  669. End Sub
  670.  
  671. Sub tDay_LostFocus ()
  672. tVal = Val(tDay.Text)
  673. If tVal < 1 Or tVal > 31 Then
  674.    tVal = 1
  675. End If
  676. tDay.Text = Format$(tVal, "00")
  677. End Sub
  678.  
  679. Sub tHour_GotFocus ()
  680. tHour.SelStart = 0
  681. tHour.SelLength = 2
  682. Active$ = "h"
  683. End Sub
  684.  
  685. Sub tHour_KeyPress (KeyAscii As Integer)
  686. If KeyAscii >= 32 Then
  687.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  688. End If
  689.  
  690. End Sub
  691.  
  692. Sub tHour_LostFocus ()
  693. tVal = Val(tHour.Text)
  694. If tVal < 1 Or tVal > 12 Then
  695.    tVal = 12
  696. End If
  697. tHour.Text = Format$(tVal, "0")
  698. End Sub
  699.  
  700. Sub tMinute_GotFocus ()
  701. tMinute.SelStart = 0
  702. tMinute.SelLength = 2
  703. Active$ = "m"
  704. End Sub
  705.  
  706. Sub tMinute_KeyPress (KeyAscii As Integer)
  707. If KeyAscii >= 32 Then
  708.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  709. End If
  710.  
  711. End Sub
  712.  
  713. Sub tMinute_LostFocus ()
  714. tVal = Val(tMinute.Text)
  715. If tVal <= 0 Or tVal > 59 Then
  716.    tVal = 0
  717. End If
  718. tMinute.Text = Format$(tVal, "00")
  719. End Sub
  720.  
  721. Sub tMonth_GotFocus ()
  722. tMonth.SelStart = 0
  723. tMonth.SelLength = 2
  724. Active$ = "n"
  725. End Sub
  726.  
  727. Sub tMonth_KeyPress (KeyAscii As Integer)
  728. If KeyAscii >= 32 Then
  729.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  730. End If
  731. End Sub
  732.  
  733. Sub tMonth_LostFocus ()
  734. tVal = Val(tMonth.Text)
  735. If tVal < 1 Or tVal > 12 Then
  736.    tVal = 12
  737. End If
  738. tMonth.Text = Format$(tVal, "00")
  739. End Sub
  740.  
  741. Sub tSecond_GotFocus ()
  742. tSecond.SelStart = 0
  743. tSecond.SelLength = 2
  744. Active$ = "s"
  745. End Sub
  746.  
  747. Sub tSecond_KeyPress (KeyAscii As Integer)
  748. If KeyAscii >= 32 Then
  749.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  750. End If
  751. End Sub
  752.  
  753. Sub tSecond_LostFocus ()
  754. tVal = Val(tSecond.Text)
  755. If tVal <= 0 Or tVal > 59 Then
  756.    tVal = 0
  757. End If
  758. tSecond.Text = Format$(tVal, "00")
  759. End Sub
  760.  
  761. Sub tYear_GotFocus ()
  762. tYear.SelStart = 0
  763. tYear.SelLength = 4
  764. Active$ = "y"
  765. End Sub
  766.  
  767. Sub tYear_KeyPress (KeyAscii As Integer)
  768. If KeyAscii >= 32 Then
  769.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  770. End If
  771.  
  772. End Sub
  773.  
  774. Sub tYear_LostFocus ()
  775. tVal = Val(tYear.Text)
  776. If tVal < 100 Then tVal = tVal + 1900
  777. If tVal < 1980 Or tVal > 2050 Then
  778.    tVal = 1980
  779. End If
  780. tYear.Text = Format$(tVal, "0000")
  781. End Sub
  782.  
  783.